package com.pan.kang.data;


import com.pan.kang.constant.MockTypeEnum;
import com.pan.kang.data.Impl.*;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

public class DataGeneratorFactory {

    private DataGeneratorFactory() {
    }

    private static final Map<MockTypeEnum, DataGenerator> mockTypeDataGeneratorMap =
            new HashMap<MockTypeEnum, DataGenerator>() {{
                put(MockTypeEnum.NONE, new NullDataGenerator());
                put(MockTypeEnum.DEFAULT, new DefaultDataGenerator());
                put(MockTypeEnum.FIXED, new FixedDataGenerator());
                put(MockTypeEnum.RANDOM, new RandomDataGenerator());
                put(MockTypeEnum.RULE, new RuleDataGenerator());
                put(MockTypeEnum.DICT, new DictDataGenerator());
                put(MockTypeEnum.INCREASE, new IncreaseDataGenerator());
            }};


    public static DataGenerator getGenerator(MockTypeEnum mockTypeEnum) {
        mockTypeEnum = Optional.ofNullable(mockTypeEnum).orElse(MockTypeEnum.NONE);
        return mockTypeDataGeneratorMap.get(mockTypeEnum);
    }
}
